/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __58F49B23_5FAC_4E67_997A_F77F5FB55D34__
#define __58F49B23_5FAC_4E67_997A_F77F5FB55D34__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 
namespace xos_box
{
    // 
    // 链表定义
    // 
    namespace xos_list
    {
        typedef xos_stl::interface_list< xos::i_release, thread_lock > ITEM_LIST;
        typedef ITEM_LIST::reverse_iterator ITEM_RITER;
        typedef ITEM_LIST::iterator ITEM_ITER;
    }

    // 
    // list iter
    // 
    class list_iter : public xos_stl::mem_item< xos::release_impl< list_iter >, thread_lock >,
        public i_list_iter
    {
    public:
        typedef xos::release_impl< list_iter > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        static int get_xos_item_data( ITEM_DATA*& item_ptr );

    public:
        list_iter();
        ~list_iter();

    protected:
        xos_list::ITEM_RITER m_r_iter;
        xos_list::ITEM_RITER m_r_end;
        xos_list::ITEM_ITER m_iter;
        xos_list::ITEM_ITER m_end;

        xos_list::ITEM_LIST * m_pList;
        bool m_bForward;

    public:
        int set( xos_list::ITEM_LIST * pList, bool bForward );
        int init_data();
        int init();
        int term();

    public:
        xos::i_release * next();
        int reset();

    };
}

#endif // __58F49B23_5FAC_4E67_997A_F77F5FB55D34__
